package com.teaching.teachingsupport.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.teachingsupport.common.pojo.dataobject.NotificationScope;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NotificationScopeMapper extends BaseMapper<NotificationScope> {
    
    @Select("SELECT DISTINCT n.notification_id FROM notification_scope n " +
            "WHERE n.scope_type = 1 " +  // 全校可见
            "OR (n.scope_type = 2 AND n.target_id = #{collegeId}) " +  // 学院可见
            "OR (n.scope_type = 3 AND n.target_id = #{majorId}) " +    // 专业可见
            "OR (n.scope_type = 4 AND n.target_id = #{classId})")      // 班级可见
    List<Long> findVisibleNotificationIds(@Param("collegeId") Long collegeId,
                                        @Param("majorId") Long majorId,
                                        @Param("classId") Long classId);
} 